<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePersonalInfoTable extends Migration
{
    /**
     * 作者 柯良志
     * 个人用户  数据表
     * 添加时间 201-7-28
     */
    public function up(){
        /** 个人用户表 personal_users  **/
        Schema::create('personal_users', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('uid')->unsigned()->comment('自动增长主键');
            $table->string('username', 60)->unique('username')->default('')->comment('用户名');
            $table->string('password', 60)->default('')->comment('密码');
            $table->string('mobile', 11)->unique('mobile')->nullable()->comment('手机');
            $table->string('email', 60)->default('')->comment('邮箱');
            $table->timestamp('regtime')->nullable()->comment('注册时间');
            $table->timestamp('updatetime')->nullable()->comment('更新时间');
            $table->string('remember_token',100)->nullable()->comment('记住登录密码');
            $table->string('api_token',60)->nullable()->comment('手机api验证字段');
            $table->timestamp('last_login_time')->nullable()->comment('最后登陆时间');
            $table->string('last_login_ip')->default('')->comment('最后登陆ip');
            $table->string('device_token',60)->nullable()->comment('设备标识(Api)');
            $table->tinyInteger('email_id')->unsigned()->default(0)->comment('验证邮箱是不是绑定');
            $table->tinyInteger('mobile_id')->unsigned()->default(0)->comment('验证手机是不是绑定');
            $table->string('qqopenid',64)->unique('qqopenid')->nullable()->comment('验证qq是不是绑定');
            $table->string('wechatopenid',64)->unique('wechatopenid')->nullable()->comment('验证微信是不是绑定');
            $table->string('wechatmpopenid',64)->unique('wechatmpopenid')->nullable()->comment('微信公众平台');
            $table->string('wechatunionid',64)->unique('wechatunionid')->nullable()->comment('微信unionid');
        });

        /** 个人简历表 resume   **/
        Schema::create('resume', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->integer('uid')->unsigned()->index('uid')->default(0)->comment('所属用户id');
            $table->string('resume_name', 100)->default('')->comment('简历名称');
            $table->tinyInteger('default')->unsigned()->default(1)->comment('多份简历(1代表默认简历，0代表多份)');
            $table->string('name', 60)->default('')->comment('姓名');
            $table->tinyInteger('sex')->unsigned()->default(0)->comment('性别');
            $table->date('birthday')->default('0000-00-00')->comment('生日');
            $table->tinyInteger('education')->unsigned()->default(0)->comment('学历');
            $table->mediumInteger('homeaddress')->unsigned()->default(0)->comment('现住址');
            $table->string('expectedsalary', 12)->default('')->comment('期望薪资');
            $table->tinyInteger('isexpectedsalary')->nullable()->comment('显示面议');
            $table->tinyInteger('work_year')->unsigned()->default(0)->comment('相关工作经验');
            $table->string('intentionjobs',60)->default('')->comment('意向工作岗位');
            $table->mediumInteger('jobsort1')->unsigned()->default(0)->comment('工作岗位1');
            $table->mediumInteger('jobsort2')->unsigned()->default(0)->comment('工作岗位2');
            $table->mediumInteger('jobsort3')->unsigned()->default(0)->comment('工作岗位3');
            $table->mediumInteger('jobsort4')->unsigned()->default(0)->comment('工作岗位4');
            $table->mediumInteger('jobsort5')->unsigned()->default(0)->comment('工作岗位5');
            $table->mediumInteger('jobarea1')->unsigned()->default(0)->comment('工作地区1');
            $table->mediumInteger('jobarea2')->unsigned()->default(0)->comment('工作地区2');
            $table->mediumInteger('jobarea3')->unsigned()->default(0)->comment('工作地区3');
            $table->mediumInteger('jobarea4')->unsigned()->default(0)->comment('工作地区4');
            $table->mediumInteger('jobarea5')->unsigned()->default(0)->comment('工作地区5');
            $table->text('introduction')->default('')->comment('介绍或技能介绍');
            $table->string('mobile', 12)->default('')->comment('手机');
            $table->string('email', 100)->default('')->comment('邮箱');
            $table->string('qq', 20)->default('')->comment('qq');
            $table->timestamp('regtime')->nullable()->comment('简历注册时间');
            $table->timestamp('updatetime')->nullable()->comment('简历更新时间');
            $table->tinyInteger('chkphoto_open')->unsigned()->default(0)->comment('简历中隐藏照片');
            $table->string('avatar',60)->default('')->comment('个人头像');
            $table->string('address',255)->default('')->comment('详细地址');
            $table->tinyInteger('job_status')->unsigned()->default(1)->comment('求职状态(不在职，正在找工作|在职，打算近期换工作)');
            $table->tinyInteger('resume_status')->unsigned()->default(0)->comment('0代表1完全公开2不公开3完全保密4代表删除');
            $table->tinyInteger('bkresume_status')->unsigned()->default(1)->comment('1完全公开2不公开3完全保密');
            $table->mediumInteger('census')->unsigned()->default(0)->comment('户籍');
            $table->tinyInteger('marital')->unsigned()->default(0)->comment('婚姻状况');
            $table->tinyInteger('height')->unsigned()->default(0)->comment('身高');
        });



        /** 工作经历表 resume_work_exp **/
        Schema::create('resume_work_exp', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->integer('resume_id')->unsigned()->index('resume_id')->default(0)->comment('简历id');
            $table->integer('uid')->unsigned()->index('uid')->default(0)->comment('所属用户id');
            $table->string('company', 60)->default('')->comment('公司名称');
            $table->smallInteger('industry')->unsigned()->default(0)->comment('所属行业');
            $table->tinyInteger('comkind')->unsigned()->default(0)->comment('公司性质');
            $table->string('scale')->default('')->comment('公司规模');
            $table->date('starttime')->default('0000-00-00')->comment('在职时间');
            $table->date('endtime')->default('0000-00-00')->comment('离职时间	Null代表在职');
            $table->string('post', 60)->default('')->comment('职位名称');
            $table->text('content')->default('')->comment('工作描述');
            $table->timestamp('addtime')->nullable()->comment('添加时间');
            $table->timestamp('updatetime')->nullable()->comment('更新时间');
        });

        /** 教育培训经历表 resume_education_exp  **/
        Schema::create('resume_education_exp', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->integer('resume_id')->unsigned()->index('resume_id')->default(0)->comment('简历id');
            $table->integer('uid')->unsigned()->index('uid')->default(0)->comment('所属用户id');
            $table->tinyInteger('edu_type')->unsigned()->nullable()->comment('教育类型');
            $table->string('school', 60)->default('')->comment('学校名称');
            $table->date('starttime')->default('0000-00-00')->comment('就读时间');
            $table->date('endtime')->default('0000-00-00')->comment('结束时间	Null代表在校');
            $table->string('speciality',200)->default('')->comment('专业名称');
            $table->tinyInteger('education')->unsigned()->default(0)->comment('学历	Null代表培训');
            $table->tinyInteger('type')->unsigned()->default(0)->comment('是否统招');
            $table->text('description')->default('')->comment('描述');
            $table->timestamp('addtime')->nullable()->comment('添加时间');
            $table->timestamp('updatetime')->nullable()->comment('更新时间');
        });

        /** 项目经验表 resume_project_exp   **/
        Schema::create('resume_project_exp', function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->integer('resume_id')->unsigned()->index('resume_id')->default(0)->comment('简历id');
            $table->integer('uid')->unsigned()->index('uid')->default(0)->comment('所属用户id');
            $table->string('project_name', 60)->default('')->comment('项目名称');
            $table->date('starttime')->default('0000-00-00')->comment('项目开始时间');
            $table->date('endtime')->default('0000-00-00')->comment('结束时间	Null代表在职');
            $table->string('post', 60)->default('')->comment('担任职务');
            $table->text('content')->default('')->comment('项目介绍');
            $table->timestamp('addtime')->nullable()->comment('添加时间');
            $table->timestamp('updatetime')->nullable()->comment('更新时间');
        });
    }


    /**
     * 作者 柯良志
     * 个人用户数据表  Reverse the migrations.
     * 添加时间 201-7-28
     */
    public function down(){
        Schema::dropIfExists('personal_users');
        Schema::dropIfExists('resume');
        Schema::dropIfExists('resume_work_exp');
        Schema::dropIfExists('resume_education_exp');
        Schema::dropIfExists('resume_project_exp');
    }
}
